<?php /*a:1:{s:66:"D:\web\wwwroot\tp5.1\public/../app/admin\view\partition\index.html";i:1526896061;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>区服列表</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">



<div class="tab-top">
<?php if(ahuthbtn('addnotice')): ?>
  <a class="layui-btn site-demo-active layui-btn-sm" data-type="tabAdd" href="<?php echo url('admin/Partition/add'); ?>"><i class="layui-icon layui-icon-add-circle"></i>添加分区</a>
<?php endif; ?>
<div class="search">
  <form class="layui-form" action="">
  <div class="layui-inline">
    <input class="layui-input layui-input-sm" name="search" placeholder="请输入分区名称" id="search-elm" autocomplete="off" value="<?php echo htmlentities($search); ?>">
  </div>
  <button class="layui-btn site-demo-active layui-btn-sm search-btn" data-type="reload">搜索</button>
</form>
</div>

</div>
<div class="layui-form">
  <table class="layui-table" lay-filter="parse-table-demo" id="test33" style="display:none">
      <colgroup>
    <col width="50">
    <col width="80">
    <col minwidth="300">
    <col width="180">
    <col width="100">
    <col width="150">
    <col width="150">
    <col width="128">
    <col>
  </colgroup>

    <thead>
      <tr>
        <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
        <th lay-data="{field:'id', width:80, sort: true}">ID</th>
        <th lay-data="{field:'name', minwidth:300}">区服名称</th>
        <th lay-data="{field:'num', minwidth:300}">编号</th>
        <th lay-data="{field:'platform', width:180,}">平台</th>
        <th lay-data="{field:'click', width:100}">备注</th>
        <th lay-data="{field:'update_time', width:150}">时间</th>
        <th lay-data="{field:'status', width:100, templet: '#statusTpl', unresize: true}">状态</th>
        <th lay-data="{field: 'right', width:128, align:'center'}">操作</th>
      </tr> 
    </thead>
    <tbody>
<?php foreach($list as $key=>$vo): ?> 
      <tr>
        <td></td>
        <td><?php echo htmlentities($vo['id']); ?></td>
        <td ><a data-href="<?php echo url('admin/Partition/selectpartition',['id'=>$vo['id']]); ?>" class="select-partition"><?php echo htmlentities($vo['name']); ?></a></td>
        <td><?php echo htmlentities($vo->num); ?></td>
        <td><?php echo htmlentities($vo->platform->name); ?></td>
        <td><?php echo htmlentities($vo->remark); ?></td>
        <td><?php echo htmlentities(date('Y-m-d H:i',!is_numeric($vo['update_time'])? strtotime($vo['update_time']) : $vo['update_time'])); ?></td>
        <td><?php echo htmlentities($vo['status']); ?></td>
        <td> 
          <?php if(ahuthbtn('edit')): ?>
          <a class="layui-btn layui-btn-xs" href="<?php echo url('admin/Partition/edit',['id'=>$vo['id']]); ?>"><i class="layui-icon layui-icon-edit"></i></a>  
          <?php endif; if(ahuthbtn('delete')): ?>
          <a class="layui-btn layui-btn-danger layui-btn-xs article-del" data-href="<?php echo url('admin/Partition/delete',['id'=>$vo['id']]); ?>"><i class="layui-icon layui-icon-delete"></i></a>
          <?php endif; ?>
        </td>
      </tr>
<?php endforeach; ?>
    </tbody>
  </table>

</div>

<div class="list-page"><?php echo $page; ?></div>
<script type="text/html" id="statusTpl">
  <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="禁|否" lay-filter="lockstatus" {{ d.status == 0 ? 'checked' : '' }} >
</script>
<div class="list-all-btn layui-row">
<?php if(ahuthbtn('delall')): ?>
 <a class="layui-btn layui-btn-danger layui-btn-sm" data-type="tabdel" id="alldel"><i class="layui-icon layui-icon-delete"></i>批量删去</a>
<?php endif; ?>
</div>
<script type="text/javascript" src="/static/frame/layui/layui.js"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['layer','form','table','admin'], function() {
  var $ = layui.jquery,
    layer = layui.layer
          ,form = layui.form
          ,admin = layui.admin
          ,table = layui.table;


          table.init('parse-table-demo', { //转化静态表格
            id:'idTest',
            //height: 'full-500'
          }); 
    
   
      //监听锁定操作
      form.on('switch(lockstatus)', function(obj){
        if(obj.elem.checked === true){
           var isval =0;
        }else{
          var isval =1;
        }
        $.post("<?php echo url('admin/Partition/quickedit'); ?>",{id:this.value,status:isval},function(data,status){
            if(data){
              layer.tips(data.msg,obj.othis);
            }
        });
      });
    
        //监听表格复选框选择
        table.on('checkbox(parse-table-demo)', function(obj){
          console.log(obj)
        });

        /**
         * 批量删去
         */
        $('#alldel').on('click', function() {

            var checkStatus = table.checkStatus('idTest'),
                data = checkStatus.data;
            var list = '';
            $.each(data, function(i,obj) {
                list += obj.id + ',';
            });
            list = list.substr(0, (list.length - 1));
            //console.log(list);

            var ids = list //得到 1，2，4
            var url = "<?php echo url('admin/Partition/delall'); ?>";
            var sUrl = "<?php echo url('admin/Partition/index'); ?>";
            var eUrl = "<?php echo url('admin/Partition/index'); ?>";
            //console.log(ids);
            //deleteAll(ids,请求的url,操作成功跳转url,操作失败跳转url)
            admin.deleteAll(ids, url, sUrl, eUrl);
        });

  $('.select-partition').click(function(event) {
    var href = $(this).attr('data-href');
    //console.log($(".game-url", parent.document).attr('href-url'));
    $.get(href, function(data) {
      if (data.code == 1) {
        var nid = data.data.partitionid; //新id
        $.each($(".layui-nav-tree", parent.document).find('.game-url'),function(i,e){
          var ourl = $(e).attr('href-url'); //老url
          var index = ourl.indexOf('?');
          var nurl = '';
          if (index > 0) {
            nurl = ourl.substring(0, index) + "?id=" + nid; //新url
            //console.log(nurl);
            $(e).attr('href-url',nurl);
          }
        });
        $(".my-header-logo", parent.document).text(data.data.partitionname);
        layer.msg(data.msg);
      } else {
        layer.msg(data.msg);
      }
    });
  });

  $('.article-del').on('click', function() {
    var href = $(this).attr('data-href');
    var trelm = $(this).parents('tr');
    layer.confirm('真的删除行么', function() {
      $.get(href, function(data) {
        if (data.code == 1) {
          layer.msg(data.msg);
          trelm.remove(); //js删去当前行
        } else {
          layer.msg(data.msg);
        }
      });
    });
  });
});


 
//indow.parent.document.getElementByIdx_x("ceeee");

// $('#ss').click(function(){
//   $("#ceeee", parent.document).text('123dsfsfs');
// });


</script>
</body>
</html>